#!/bin/sh
#############################
# Mac OS X 1.5.6
# author	: sgxiao
# version 	: 0.1
# history 
#	sgxiao	0.1	make name	
#############################

IMPORT_FILE_TYPE=txt
EXPORT_FILE_TYPE=data

# make sure what's the useful file in this folder
ls -l | grep ${IMPORT_FILE_TYPE} > filename.1.temp
awk '{print $9}' filename.1.temp > filename.2.temp

# make filename array for extract daily price
awk -f filename_to_array.awk filename.2.temp > filename_array.sh
rm *.temp


#filename_array.sh
# generator of extract_daily_price.sh
filenames=`wc -l filename_array.sh | awk '{print $1}'`
echo ${filenames} files are there in processing...
cat extract_daily_price.tample.sh > extract_daily_price.sh
cat filename_array.sh >> extract_daily_price.sh

############
echo "i=0
while [ \$i -le $((filenames-1)) ]" >> extract_daily_price.sh
############

cat extract_daily_price.tample.2.sh >> extract_daily_price.sh

chmod a+x extract_daily_price.sh
./extract_daily_price.sh
mv *.${EXPORT_FILE_TYPE} ../..
